import Taro, { PureComponent } from '@tarojs/taro';
import { View, Text, Button } from '@tarojs/components';
import { AtTabBar } from 'taro-ui'
import Home from './home'
import Mine from './mine'
import ImgHome from '../../images/home.png'
import ImgHomeSelected from '../../images/home_selected.png'
import ImgUser from '../../images/user.png'
import ImgUserSelected from '../../images/user_selected.png'

class Index extends PureComponent {

  config = {
    navigationBarTitleText: '首页'
  }

  state = {
    current: 0
  }

  componentWillMount() { }
  componentDidMount() { }
  componentWillReceiveProps(nextProps, nextContext) { }
  componentWillUnmount() { }
  componentDidShow() { }
  componentDidHide() { }
  componentDidCatchError() { }
  componentDidNotFound() { }
  render() {
    const { current } = this.state
    return (
      <View>
        {current == 0 ? <Home /> : null}
        {current == 1 ? <Mine /> : null}
        <AtTabBar fixed
          current={current}
          color="#666"
          selectedColor="#d81e06"
          onClick={current => {
            this.setState({ current })
          }}
          tabList={[{
            title: "首页",
            image: ImgHome,
            selectedImage: ImgHomeSelected,
          }, {
            title: "我",
            image: ImgUser,
            selectedImage: ImgUserSelected,
          }]} />
      </View>
    );
  }
}
export default Index;